package com.grt192.deploy;

import javax.swing.JFrame;

import simulator.Simulator;

import com.grt192.mechanism.CreateBase;

public class MainRobot {

	public static void main(String[] args) {

		JFrame home = new JFrame("Simulator");

		final Simulator sim = new Simulator();

		sim.customConfiguration(new String[] { "maze/" + "Super" + ".maze" });

		// mechs
		final CreateBase base = new CreateBase(sim);

		home.getContentPane().add(sim);
		home.setLocation(200, 200);
		home.setSize(1000, 300);
		home.setVisible(true);
		home.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

		// ADD ACTOR(S)
		// Actor b = new Ed();
		// sim.customConfiguration(new String[] { "maze/" + b.getMaze() +
		// ".maze" });
		// sim.addActor(b);

		// This actor will serve telemetry data for Dashboard and client apps
		// Actor c = new SnitchActor();
		// sim.addActor(c);
		// ((SnitchActor) c).start();

		new Thread() {
			public void run() {
				sim.mainLoop();
			}
		}.start();
		// Start Simulation
		// instantiate actuators

		// instantiate sensors

		// try {
		// Thread.sleep(10000);
		// } catch (InterruptedException e1) {
		// // TODO Auto-generated catch block
		// e1.printStackTrace();
		// }

		base.goForward();
		base.waitDistance(1);
		base.halt();

		while (true) {

			for (int i = 0; i < 10; i++) {
				System.out.println(i);
				if (i == 0) {
					System.out.println("Drive");
					base.goForward();
					base.waitDistance(10);

				}

				try {
					Thread.sleep(500);
				} catch (InterruptedException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}

			}
		}

	}
}
